package com.qyer.commons.concurrent;

import java.util.concurrent.CountDownLatch;

/**
 * User: Z J Wu Date: 2016/07/28 Time: 09:53 Package: com.qyer.commons.concurrent
 */
public abstract class RecordProcessorTransmitter<T extends PoisonPill<T>, R extends
  PoisonPill<R>> extends RecordProcessor<T> {

  protected GenericLinkedBlockingQueue<R> queue2;

  public RecordProcessorTransmitter(String name, GenericLinkedBlockingQueue<T> queue1,
                                    CountDownLatch stopSignal,
                                    GenericLinkedBlockingQueue<R> queue2) {
    super(name, queue1, stopSignal);
    this.queue2 = queue2;
  }

  public abstract R innerProcess(T t) throws Exception;

  public final void process(T t) throws Exception {
    R r = innerProcess(t);
    queue2.put(r);
  }

}
